libxl: Introduce pci_assignable_add and pci_assignable_remove
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Tue, 15 May 2012 15:28:15 +0000 (16:28 +0100)
committerGeorge Dunlap <george.dunlap@eu.citrix.com>
Tue, 15 May 2012 15:28:15 +0000 (16:28 +0100)
commit039a5e5322fcf5cdcff2315db11cdd46919db534
tree2dc08644d79e034b26f1de2ce0d127b771f74981
parent0773a6e830f805cc288a3f542daa67be400be1cd
libxl: Introduce pci_assignable_add and pci_assignable_remove

Introduce libxl helper functions to prepare devices to be passed
through to guests.  This is meant to replace of all the manual sysfs
commands which are currently required.

pci_assignable_add accepts a BDF for a device and will:
* Unbind a device from its current driver, if any
* If "rebind" is set, it will store the path of the driver from which we
  unplugged it in /libxl/pciback/$BDF/driver_path
* If create a slot for it in pciback if one doesn't yet exist
* Bind the device to pciback

At this point it will show up in pci_assignable_list, and is ready to
be passed through to a guest.

pci_assignable_remove accepts a BDF for a device and will:
* Unbind the device from pciback
* Remove the slot from pciback
* If "rebind" is set, and /libx/pciback/$BDF/driver_path exists, it
  will attempt to rebind the device to its original driver.

Both functions are idempotent: if the desired end state has already
been reached, they return SUCCESS.

NB that "$BDF" in this case uses '-' instead of ':' and '.', because
':' and '.' are illegal characters in xenstore paths.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.h
tools/libxl/libxl_pci.c